package com.taskflow.service;

import com.taskflow.common.PageResult;
import com.taskflow.dto.LogQueryDTO;
import com.taskflow.entity.DownloadLog;
import com.taskflow.mapper.DownloadLogMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 下载日志Service
 */
@Service
public class DownloadLogService {

    @Autowired
    private DownloadLogMapper logMapper;

    public Long createLog(DownloadLog log) {
        logMapper.insert(log);
        return log.getId();
    }

    public void updateLog(DownloadLog log) {
        logMapper.update(log);
    }

    public DownloadLog getLogById(Long id) {
        return logMapper.selectById(id);
    }

    public PageResult<DownloadLog> getLogList(LogQueryDTO query) {
        List<DownloadLog> list = logMapper.selectList(query);
        Long total = logMapper.selectCount(query);
        return new PageResult<>(list, total, query.getCurrent(), query.getSize());
    }
}

